package fy.hr.staffRedeploy;

import java.util.List;

import org.json.JSONObject;

import fy.hr.bean.JobBean;


public class StaffingNeedsManager {

	private String memberCode;

	private String postRankMapJSON;

	private String postNumJSON;

	private String postOptions;

	public String getPostNumJSON() {
		return postNumJSON;
	}

	public String getPostRankMapJSON() {
		return postRankMapJSON;
	}

	public String getPostOptions() {
		return postOptions;
	}

	public void setMemberCode(String memberCode) {
		this.memberCode = memberCode;
	}

	public void query() throws Exception {
		List<JobBean> jobBeans = StaffingNeedsDao.queryPostAndRank(memberCode);
		if (jobBeans != null) {
			StringBuilder sb = new StringBuilder();
			JSONObject jo = new JSONObject();
			JSONObject numJo = new JSONObject();
			for (int i = 0, length = jobBeans.size(); i < length; i++) {
				sb.append(" <option value =").append(jobBeans.get(i).getId())
						.append(">").append(jobBeans.get(i).getName())
						.append("</option>");

				jo.put(jobBeans.get(i).getId(), jobBeans.get(i).getRank());
				numJo.append(jobBeans.get(i).getId(), jobBeans.get(i)
						.getWorkout());
				numJo.append(jobBeans.get(i).getId(), jobBeans.get(i)
						.getActualnum());
			}
			postRankMapJSON = jo.toString();
			postOptions = sb.toString();
			postNumJSON = numJo.toString();
		}

	}
}
